<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="keywords" content="">
  <meta name="description" content="">
  <title>审批历史</title>
  <link href="/static/css/bootstrap.min.css" rel="stylesheet"/>
  <link rel="stylesheet" href="/static/include/css/style.css">
</head>
<body class="white-bg" style="height: 95%">

<div class="wrapper-content">
  <table id="bootstrap-table"></table>
</div>


<script src="/static/include/js/footer.js"></script>
<script>
  $(function () {
    var OpinionStatus = {};
    $.ajax({
      url: api+'/scabpm/sys/tools/getEnum',
      data:{
        path: 'com.dstz.bpm.api.constant.OpinionStatus',
        listMode: false
      },
      async: false,
      type: 'post',
      success: function (res) {
        Object.values(JSON.parse(res)).forEach(function(item){
          OpinionStatus[item.key] = item.value
        })
      }
    });

    var options = {
      url: api + "/scabpm/bpm/instance/getOpinion",
      method: 'post',
      listType: 'bpm',
      modalName: "审批历史",
      pagination: false,
      showSearch: false,
      showRefresh: false,
      showToggle: false,
      showColumns: false,
      queryParams: function (params) {
        var data = {
          instId: getQueryString('id'),
          taskId: '',
        };
        return data
      },
      columns: [
        {
          field: 'taskName',
          title: '任务名称'
        },
        {
          field: 'createTime',
          title: '任务创建时间'
        },
        {
          field: 'approveTime',
          title: '处理时间'
        },
        {
          field: 'assignInfo',
          title: '候选人',
          formatter: function (value, row, index) {
            return userInfo(value)
          }
        },
        {
          field: 'approverName',
          title: '执行人'
        },
        {
          field: 'status',
          title: '动作',
          formatter: function (value, row, index) {
            return OpinionStatus[value]
          }
        },
        {
          field: 'opinion',
          title: '备注/意见'
        },
        ]
    };
    $.table.init(options);

    function userInfo(info){
      if (!info) {
        return "";
      }
      if(info.indexOf("-")==-1){
        return info;
      }
      var msg = "";
      info.split(",").forEach(function(item) {
        if (!item) {
          return;
        }
        if (msg) {
          msg += "；";
        }
        var strs = item.split("-");
        var typeName = "";
        if (strs[0] === "user") {
          typeName = "[用户]";
        } else if (strs[0] === "role") {
          typeName = "[角色]";
        } else if (strs[0] === "group") {
          typeName = "[组]";
        } else if (strs[0] === "org") {
          typeName = "[组织]";
        } else if (strs[0] === "post") {
          typeName = "[岗位]";
          if (strs[2]) {
            return msg += typeName + strs[1] + "-" + strs[2];
          }
        } else if (strs[0] === "job") {
          typeName = "[职称]";
        }
        msg += typeName + strs[1];
      });
      return msg;
    }

  })

  function submitHandler(index, layero) {
    $.modal.close()
  }




</script>
</body>
</html>
